package test;

import data.IntegerDataSetGenerator;
import impl.*;

import java.util.List;

public class PruebaSimple {

    public static void main(String[]ars){

        IntegerDataSetGenerator generador = new IntegerDataSetGenerator();
/*
        //BUBBLE
        printSort(new BubbleSorter(), generador);

        //SELECTION
        printSort(new SelectionSorter(), generador);

        //INSERTION
        printSort(new InsertionSorter(), generador);

        //QUICK Recursive
        printSort(new QuickSorter(), generador);

        //QUICK CutOff
        printSort(new QuickSorterCutOff(10), generador);

        //QUICK Non Recursive
        printSort(new QuickSorterNonRecursive(), generador);
*/
        //QUICK Three Way       chequeo de baja chance de error
        QuickSorterThreeWay a;
        int cant = 0;
        for(int m = 0; m<10; m++){
            a = new QuickSorterThreeWay();
            printSort(a, generador);
            if(a.getBienOrdenado()){
                cant++;
            }
        }
        System.out.println(cant);
/*
        //HSort
        printSort(new HSorter(), generador);

        //ShellSort
        int[] secuencia = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841};
        printSort(new ShellSorter(secuencia), generador);

        //MergeSortBottomUp
        printSort(new MergeSorterBottomUp(), generador);
*/
    }


    private static void printSort(AbstractSorter sort, IntegerDataSetGenerator generador){

        System.out.print(sort.getType().name()+": ");
        System.out.println();
        List array = generador.createRandom(20);
        System.out.print("Desordenado: ");
        for (Object anArray : array) {
            System.out.print(" " + anArray);
        }
        System.out.println();
        sort.sort(generador.getComparator(), array);
        System.out.print("Ordenado: ");
        for (Object anArray : array) {
            System.out.print(" " + anArray);
        }
        System.out.println();
        System.out.println();
    }
}
